<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<jsp:include page="../include/header.jsp" />
<jsp:include page="../include/navigation.jsp" />

<h2>Find new media</h2>
<p>Moviereminder is currently only searching on <a href="http://www.themoviedb.org/">TMDB</a></p>

<div>
	<form action="${baseUrl}/findmovie/search" method="get">
		<input class="cleanInput focusOnPageLoad" type="text" name="search" size="40" value="${search}" />
		<input type="submit" class="submit" value="find" />
	</form>
</div>

<c:if test="${!empty search}">
	<div id="movieResults" class="result">
		<c:choose>
			<c:when test="${!empty movies}">
				<h3>Matches on tmdb.org for &quot;<strong>${search}</strong>&quot;:</h3>
				<ul>
					<c:forEach items="${movies}" var="movie" varStatus="status">
						<li>
							<a href="info/${movie.sourceId}">
								<c:choose>
									<c:when test="${!empty movie.coverUrl}">
										<img class="cover" width="140" height="224" src="${movie.coverUrl}" />
									</c:when>
									<c:otherwise>
										<img class="cover" width="140" height="224" src="${baseUrl}/img/noposter.jpg" />
									</c:otherwise>
								</c:choose>
							</a>
							<p class="movieTitle">
								<a href="info/${movie.sourceId}">${movie.name}</a><br/>
								 Released: (<fmt:formatDate pattern="yyyy" value="${movie.releasedDate}" />)
							</p>
						</li>
					</c:forEach>
				</ul>
				<div class="clear"></div>
			</c:when>
			<c:otherwise>
				<h3>No matches found for &quot;${search}&quot;...</h3>
		</c:otherwise>
	</c:choose>
	</div>
</c:if>

<jsp:include page="../include/footer.jsp" />